#include "Classes.h"

Game::Game() {
	// setup Irrlicht environment
	Receiver = new EventReceiver;
	Device = createDevice(EDT_OPENGL,dimension2d<u32>(1600,900),16,true,true,true,Receiver);
	Driver = Device->getVideoDriver();
	Sound = createIrrKlangDevice();
	Device->getCursorControl()->setVisible(false);

	// this will change
	Scale = 4;

	// setup Link sprite sheet
	SpritesLink = Driver->getTexture("./Graphics/SpritesLink.png");
	Driver->makeColorKeyTexture(SpritesLink,Colour::AlphaKey);

	// add Link images to vector
	for (u32 y=0; y<SpritesLink->getSize().Height/16; y++) {
		for (u32 x=0; x<SpritesLink->getSize().Width/16; x++) {
			LinkImages.push_back(rect<s32>(x*16,y*16,x*16+16,y*16+16));
		}
	}
	
	// setup Boomerang sprite sheet	
	SpritesBoomerang = Driver->getTexture("./Graphics/SpritesBoomerang.png");
	Driver->makeColorKeyTexture(SpritesBoomerang,Colour::AlphaKey);
	
	// setup Boomerang image rects
	BoomerangWoodenImages.push_back(rect<s32> (0,0,5,9));
	BoomerangWoodenImages.push_back(rect<s32> (10,0,19,5));
	BoomerangWoodenImages.push_back(rect<s32> (5,0,10,9));
	BoomerangWoodenImages.push_back(rect<s32> (10,5,19,10));

	BoomerangMetalImages.push_back(rect<s32> (0,10,5,19));
	BoomerangMetalImages.push_back(rect<s32> (10,10,19,15));
	BoomerangMetalImages.push_back(rect<s32> (5,10,10,19));
	BoomerangMetalImages.push_back(rect<s32> (10,15,19,20));

	// setup Sword sprite sheet
	SpritesSword = Driver->getTexture("./Graphics/SpritesSword.png");
	Driver->makeColorKeyTexture(SpritesSword,Colour::AlphaKey);
	ImageSwordWoodenEast = rect<s32>(14,7,33,14);
	ImageSwordWoodenSouth = rect<s32>(0,0,7,19);
	ImageSwordWoodenWest = rect<s32>(14,0,33,7);
	ImageSwordWoodenNorth = rect<s32>(7,0,14,19);

	// setup sounds
	Sounds.push_back(Sound->addSoundSourceFromFile("./Sounds/SFX_Arrow.wav"));
}

void Game::setPlayer(Player* Link_) {
	Link = Link_;
}